package edu.nyupoly.wzj;

import java.util.Scanner;

public class HumanPlayer extends Player{

	public HumanPlayer(String name,Mark mark) {
		super(name, mark);
	}
	
	public void makeMove(Board b) {
		System.out.println("It's your turn! Please input where to move? Row=[0,1,2],Col=[0,1,2]");
		
		Scanner input = new Scanner(System.in);
		
		try{
			System.out.println("Row:");
			int row = input.nextInt();
			
			System.out.println("Column:");
			int col = input.nextInt();
			
			//input.close();
			
			if(row>2 || col>2 || b.cells[row][col].claimed == true ) {
				System.out.println("Invalid Input! Please try it again! ");
				makeMove(b);
				return;
			}
			
			b.setPiece(row, col, this);
			System.out.println("Valid Input! Thanks! ");
			
		} catch (Exception e){
			
			//input.close();
			System.out.println("Input Error! Please try it again! ");
			makeMove(b);
		}
		
		//this.attempt++;
	}
	
	public boolean isWinner(Board b) {
		return b.hasWon(this.myMark);
	}

}
